home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.Accessible;
- import com.sun.java.accessibility.AccessibleContext;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Graphics;
- import java.awt.LayoutManager;
- import java.awt.Rectangle;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
-
- public class CellRendererPane extends Container implements Accessible {
- protected AccessibleContext accessibleContext = null;
-
- public CellRendererPane() {
- ((Container)this).setLayout((LayoutManager)null);
- ((Component)this).setVisible(false);
- }
-
- protected void addImpl(Component x, Object constraints, int index) {
- if (x.getParent() != this) {
- super.addImpl(x, constraints, index);
- }
- }
-
- public AccessibleContext getAccessibleContext() {
- if (this.accessibleContext == null) {
- this.accessibleContext = new AccessibleCellRendererPane(this);
- }
-
- return this.accessibleContext;
- }
-
- public void invalidate() {
- }
-
- public void paint(Graphics g) {
- }
-
- public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) {
- this.paintComponent(g, c, p, x, y, w, h, false);
- }
-
- public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) {
- if (c == null) {
- if (p != null) {
- Color oldColor = g.getColor();
- g.setColor(((Component)p).getBackground());
- g.fillRect(x, y, w, h);
- g.setColor(oldColor);
- }
-
- } else {
- if (c.getParent() != this) {
- ((Container)this).add(c);
- }
-
- c.setBounds(x, y, w, h);
- if (shouldValidate) {
- c.validate();
- }
-
- boolean wasDoubleBuffered = false;
- if (c instanceof JComponent && ((JComponent)c).isDoubleBuffered()) {
- wasDoubleBuffered = true;
- ((JComponent)c).setDoubleBuffered(false);
- }
-
- Graphics cg = SwingGraphics.createGraphics(g, x, y, w, h);
-
- try {
- c.paint(cg);
- } finally {
- cg.dispose();
- }
-
- if (c instanceof JComponent && wasDoubleBuffered) {
- ((JComponent)c).setDoubleBuffered(true);
- }
-
- if (c instanceof JComponent) {
- JComponent jc = (JComponent)c;
- jc.setDoubleBuffered(wasDoubleBuffered);
- }
-
- c.setBounds(-w, -h, 0, 0);
- }
- }
-
- public void paintComponent(Graphics g, Component c, Container p, Rectangle r) {
- this.paintComponent(g, c, p, r.x, r.y, r.width, r.height);
- }
-
- public void update(Graphics g) {
- }
-
- private void writeObject(ObjectOutputStream s) throws IOException {
- ((Container)this).removeAll();
- s.defaultWriteObject();
- }
- }
-